package org.blim.blackdawn.graph;

import java.util.ArrayList;
import java.util.List;

import org.blim.blackdawn.model.Model;

/**
 * ReferenceFrames represent a tree of nested cartesian co-ordinate systems.
 * 
 * <p>Each ReferenceFrame contains a model matrix and an animation, with its
 * own transformation matrix, which when combined describe the transformation
 * that positions the origin of this frame of reference in the co-ordinate
 * system of the parent frame of reference.</p>
 * 
 * @author lee@longlost.info
 */
public class ReferenceFrame {

	public float[] mModelMatrix = new float[16];

	public ReferenceFrame mParent;
	public final List<ReferenceFrame> mChildFrames;

	public final Model mModel;
	public Animation mAnimation;

	public ReferenceFrame() {
		this(null, null, null, null);
	}

	public ReferenceFrame(ReferenceFrame parent, 
			float[] modelMatrix,
			Model model, 
			Animation animation) {
		mModelMatrix = modelMatrix;
		mModel = model;
		mAnimation = animation;

		mChildFrames = new ArrayList<ReferenceFrame>();

		if (null != parent) {
			parent.addChild(this);
		}
	}

	public void addChild(ReferenceFrame child) {
		child.mParent = this;
		mChildFrames.add(child);
	}

}
